#!/usr/bin/env bash
# ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
# Function :CentOS7.X k8s 安装
# Platform :RedHatEL7.x Based Platform
# Version  :0.1
# Date     :2022-09-16
# Author   :mugoLH
# Contact  :hxsaj@126.com
# Company  :
# depend on:
# ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----

#  函数列表 List of common functions
########## ########## ########## ########## ########## ########## #
#  ==> 提示色彩函数
info_p()   { printf "\e[32;40m%-8s %-12s %-34s %-24s %-12s\e[0m\n"   "$(date +'%Y%m%d %T')" "${1}" "${2}" "${3}" "${4}" >&1 ;}
echo_p(){  printf "\e[1;36;40m%-10s\e[0m \e[1;32;40m%-1s %-30s%-1s\e[0m" "$(date '+%y%m%d_%H:%M:%S')" "Step:" "${1}" ":" >&1 ;}
warning()  { echo -e "\e[1;34m$(date +'%Y%m%d %T') $@ \e[0m" >&1 ; }
warning_p(){ printf "\e[1;33;40m%-8s %-12s %-34s %-24s %-12s\e[0m\n" "$(date +'%Y%m%d %T')" "${1}" "${2}" "${3}" "${4}" >&1 ;}
error_p()  { printf "\e[1;35;40m%-8s %-12s %-34s %-24s %-12s\e[0m\n" "$(date +'%Y%m%d %T')" "${1}" "${2}" "${3}" "${4}" >&1 ;}

#  ==> 关闭并禁用selinux
function selinux_off() {
    # 步骤
    echo_p "Disable Selinux"
    # 执行
    if [[ $(getenforce) = "Enforcing" ]]; then
        setenforce 0 >/dev/null 2>&1
    fi
    if [ $(grep "^SELINUX=" /etc/selinux/config | awk -F "=" '{print$2}') != "disabled" ];then
        sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
        info_p  "[ SUCCESS ]" "Selinux disable successfully"
        return 0
    else
        info_p  "[ STATUS  ]" "Disabled"
        return 0
    fi
}





#  ==> 初始化部署环境
function init_env() {